﻿@model SelfMadeMillionaire.Web.Infrastructure.ViewModels.Account.PersonalInfoViewModel
<div style="margin-top: 20px;">
	<div>
		@using (Html.BeginForm("PersonalInfo", "Profile", FormMethod.Post, new { @class = "form-horizontal" }))
  {
			<div class="form-group">
				<label for="firstName" class="col-sm-2 control-label custom_label">First Name</label>

				<div class="col-sm-7">
					@Html.TextBoxFor(m => m.FirstName, new { @class = "form-control", placeholer = "Enter your First Name" })
					@Html.ValidationMessageFor(m => m.FirstName)
				</div>
			</div>

			<div class="form-group">
				<label for="firstName" class="col-sm-2 control-label custom_label">Last Name</label>
				<div class="col-sm-7">
					@Html.TextBoxFor(m => m.LastName, new { @class = "form-control", placeholer = "Enter your Last Name" })
					@Html.ValidationMessageFor(m => m.LastName)
				</div>
			</div>

			<div class="form-group">
				<label for="firstName" class="col-sm-2 control-label custom_label">Email</label>
				<div class="col-sm-7">
					@Html.TextBoxFor(m => m.Email, new { @class = "form-control", placeholer = "Enter your email" })
					@Html.ValidationMessageFor(m => m.Email)
				</div>
			</div>

			<div class="form-group1">
				<div class="newsletter_search_btn col-lg-12">
					<button type="submit" class="btn btn-primary">Save</button>
					<a href="@Url.Action("ChangePassword", "Profile")" class="btn btn-primary">Change Password</a>
				</div>
				@if (Model.IsSuccess)
	{		
					<p style="margin-top: 20px;">Updated Successfully.</p>
	}
			</div>
  }

	</div>
</div>

<script type="text/javascript">
    $("#personalInformation button[type='submit']").click(function () {
		var form = $(this).closest("form");
		if (form.valid()) {
			$.ajax({
				url: "@Url.Action("PersonalInfo", "Profile")",
				type: "POST",
				data: form.serialize(),
				cache: false,
				success: function (result) {
                    $("#personalInformation").html(result);
				}
			});
		}

		return false;
	});

    $(document).ready(function () {
        @if (Session["AuthDataUpdated"] != null)
        {
            <text>window.location = window.location;</text>
        }

		$("#personalInformation button[type='submit']").prop("disabled", true);

		$("#FirstName").keypress(function () {
			$("#personalInformation button[type='submit']").prop("disabled", false);
		});

		$("#LastName").keypress(function () {
			$("#personalInformation button[type='submit']").prop("disabled", false);
		});

		$("#Email").keypress(function () {
			$("#personalInformation button[type='submit']").prop("disabled", false);
		});

	});
</script>
